package com.muki.wareHouse;

import java.util.HashMap;
import java.util.Map;

public class DataWareHouse extends WareHouse {

	private Map<String,CorpusHouse> corpuses = new HashMap<>();
	
	private String root = "F://Corpus/";
	
	private String getPath(String root,String cur) {
		return root+cur+"/";
	}
	
	@Override
	public void receive(CorpusParser parser,ListCorpus list){
		list.add(parser);
	}

	@Override
	public CorpusHouse createRemoteCorpusHouse(String ip, int port, String bath_path,String topic) {
		CorpusHouse house = corpuses.getOrDefault(topic,new RemoteCorpusHouse(ip,port,bath_path,new RouteMap()));
		corpuses.put(topic, house);
		return house;
	}

	@Override
	public CorpusHouse createCorpusHouse(String topic) {
		CorpusHouse house = corpuses.getOrDefault(topic,new LocalCorpusHouse(getPath(root,topic),new RouteMap()));
		corpuses.put(topic, house);
		return house;
	}

}
